<?
include("../../../../wp-config.php");
global $wpdb;
?>
<script type='text/javascript' src='<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>
<script>
	jQuery(function() {
		jQuery("#validaForm").click(function() {
			jQuery("#validaForm").hide();
			jQuery("#loading").show();

			jQuery("#email").css('background', '#FFF').focus();
			jQuery("#senha").css('background', '#FFF').focus();
			jQuery("h4").css('background', 'none');
			jQuery("#nome_stats").html('');
			jQuery("#email_stats").html('');
		
			if(jQuery("#email").val() && jQuery("#senha").val()) {
				jQuery.post("<?= get_bloginfo('template_directory'); ?>/inc/autentica.php", { email:jQuery("#email").val(), senha:jQuery("#senha").val() }, function(rs) {
					if(rs == true) {
						window.parent.location.reload();
					} else {
						jQuery("#email_stats").html('Senha Invalida!');
						jQuery("#loading").hide();
						jQuery("#validaForm").show();
					}
				});
			} else {
				if(jQuery("#email").val() == "") {
					jQuery("#email").css('background', '#FFEAEB').focus();
					jQuery("#email_stats").html('Digite seu E-mail');
				} else if(jQuery("#senha").val() == "") {
					jQuery("#senha").css('background', '#FFEAEB').focus();
					jQuery("#senha_stats").html('Digite sua Senha');
				}
				jQuery("#loading").hide();
				jQuery("#validaForm").show();
			}
		});
	});
</script>

<style>
	body { background: url('<? bloginfo('template_directory'); ?>/img/fundo.jpg') no-repeat top left; }
	.logo-cadastro { border-bottom: 3px solid #990000; padding: 10px 0; }
	#form-cadastro h5 { margin: 10px 0 0; font: 15px Tahoma; }
	#form-cadastro h4 { margin: 14px 0 0; font: 12px Tahoma; }
	#form-cadastro p { margin: 0;padding:0; }
	#form-cadastro input[type=text],
	#form-cadastro input[type=password] { border: 1px dotted #602418; width: 60%; }
	#form-cadastro input[type=button] { border: 1px dotted #000; background: #990000; color: #FFF; width: 100%; }
	#cadastro { float: left; margin: 0 5px 0 0; }
	#email_stats, #login_stats, #senha_stats { font: 12px Tahoma; color: red; }
	#loading {background: url("<? bloginfo('template_directory'); ?>/img/ajax-loader.gif") no-repeat center center;  height: 31px; width: 100%;display:none;}
</style>

<div class="logo-cadastro">
	<img src="<? bloginfo('template_directory'); ?>/img/logo_mini.jpg" border="0" />
</div>

<div id="form-cadastro">

	<form action="<?= $_SERVER['REQUEST_URI']; ?>" method="post" id="enviaForm">
		<h5>E-mail: <span id='email_stats'></span></h5>
		<p>
			<input class="textfield" type="text" name="email" size="50" id="email" />
		</p>

		<h5>Senha: <span id='senha_stats'> </span></h5>
		<p>
			<input class="textfield" type="password" name="senha" size="50" id="senha" />
		</p>
		<br />
		<input type="button" name="enviar" value="cadastrar" id="validaForm" />
		<div id="loading"></div>
	</form>

</div>
